<template slot-scope="props">
	<section>
		<el-form :inline="true" :model="formInline" class="demo-form-inline" size="medium">

			<el-form-item label="科室名称">
				<el-input class="inline-input" v-model="formInline.dmmc" @input="queryAll()" 
				 placeholder="请输入内容" />
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="queryAll()">新增</el-button>
			</el-form-item>

			<el-table :data="tableData" border fit height="400px">
				<el-table-column prop="kbxh" label="序号" min-width="70%">
					<template slot-scope="scope">
						<el-input v-model="scope.row.kbxh" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="dm" label="代码" min-width="100%">
					<template slot-scope="scope">
						<el-input v-model="scope.row.dm" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="dmmc" label="科室名称" min-width="140%">
					<template slot-scope="scope">
						<el-input v-model="scope.row.dmmc" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="kbjc" label="科室简称" min-width="100%">
					<template slot-scope="scope">
						<el-input v-model="scope.row.kbjc" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				
				<el-table-column prop="cws" label="床位数">
					<template slot-scope="scope">
						<el-input v-model="scope.row.cws" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="bz" label="是否停用" min-width="130%">
					<template slot-scope="scope">
						<el-switch v-model="scope.row.bz" active-value="1" inactive-value="0" active-text="启" inactive-text="停"
						 active-color="#13ce66" inactive-color="#ff4949" >
						</el-switch>
					</template>
				</el-table-column>
				<el-table-column label="操作" width="180" fixed="right">
					<template slot-scope="scope">
						<el-button size="mini" type="primary" @click="update(scope.row)">修改</el-button>
						<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-form>
		
	</section>
</template>

<script>
	import {
		GetObservationRoom,
		UpdateObservationRoom
	} from "@/api";
	
	export default {
		components: {
			
		},
		data() {
			return {
				restaurants: [],
				formInline: {},
				tableData: [],
			}
		},
		methods: {
			queryAll() {
				GetObservationRoom(this.formInline).then(res => {
					this.tableData = res.data.data
				})
			},
			
			update(row) {
				this.$confirm('确定要修改此项吗, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					UpdateObservationRoom(row).then(res => {
						if (res.data.code === 0) {
							this.$message({
								type: 'success',
								message: '修改成功!'
							});
						} else {
							this.$message({
								type: 'error',
								message: '修改失败请联系管理员!'
							});
						}
						this.queryAll();
					})

				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消修改'
					});
					this.queryAll();
				});

			}

		},
		mounted() {
			this.queryAll();
		}
	};
</script>

<style>
</style>

